<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue当中的计算属性和侦听器</title>
    <script src="vue.js"></script>
</head>
<body>
<div id="root">
    firstname:<input v-model="firstname"/>
    lastname:<input v-model="lastname"/>
    <div v-text="fullname"></div>
    <div v-text="count"></div>
</div>
<script>
    new Vue({
        el:"#root",
        data:{
            firstname:"",
            lastname:"",
            count:0
        },
        computed:{
            fullname: function () {
                return this.firstname + ' ' + this.lastname;
            }
        },
        watch:{
            /*firstname:function () {
                return this.count++;
            },
            lastname:function () {
                return this.count++;
            }*/
            fullname:function () {
                return this.count++;
            }
        }

    })
</script>
</body>
</html>